package com.coda.clouddisk.entity;

import com.coda.clouddisk.message.MessageContext;
import lombok.Data;

@Data
public class KesunReturn {

    private String msg;//提示信息
    private String code;//返回状态码
    private Object obj;//返回值
    public KesunReturn (){}

    public KesunReturn(String code, String msg, Object obj) {
        this.msg = msg;
        this.code = code;
        this.obj = obj;
    }
    //成功返回数据
    public KesunReturn success (Object obj){
        return new KesunReturn(MessageContext.SUCCESS_CODE,MessageContext.SUCCESS_MSG,obj);
    }
    //成功返回消息
    public KesunReturn success (String msg){
        return new KesunReturn(MessageContext.SUCCESS_CODE,msg,null);
    }
    //成功返回消息和数据
    public KesunReturn success (String msg,Object obj){
        return new KesunReturn(MessageContext.SUCCESS_CODE,msg,obj);
    }

    //错误返回消息
    public KesunReturn error (String msg){
        return new KesunReturn(MessageContext.SUCCESS_CODE,msg,null);
    }

    //错误返回消息
    public KesunReturn error (String code,String msg){
        return new KesunReturn(code,msg,null);
    }
}
